From e44c82fcf384232c9321f82e4360761f1642ef93 Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Wed, 1 Jan 2014 00:40:14 +0000 Subject: [PATCH] Another round of fixes for easygps, gpsutil, googledir, and a few others. Last one for a few hours. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4690 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/easygps.cc | 10 ++-------- gpsbabel/garmin_xt.cc | 2 +- gpsbabel/gbfile.cc | 6 ++++-- gpsbabel/gbfile.h | 2 +- gpsbabel/googledir.cc | 8 +++++--- gpsbabel/gpsutil.cc | 2 +- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/gpsbabel/easygps.cc b/gpsbabel/easygps.cc index 8270e22e5..c446aa9ae 100644 --- a/gpsbabel/easygps.cc +++ b/gpsbabel/easygps.cc @@ -99,19 +99,13 @@ data_read(void) wpt_tmp->notes = gbfgetpstr(file_in); break; case 6: { - char* ult = gbfgetpstr(file_in); + QString ult = gbfgetpstr(file_in); link.url_link_text_ = ult; - if (ult) { - xfree(ult); - } } break; case 7: { - char* id = gbfgetpstr(file_in); + QString id = gbfgetpstr(file_in); wpt_tmp->icon_descr = id; - if (id) { - xfree(id); - } } break; case 8: /* NULL Terminated (vs. pascal) descr */ diff --git a/gpsbabel/garmin_xt.cc b/gpsbabel/garmin_xt.cc index 3d46e8321..f1ee58a75 100644 --- a/gpsbabel/garmin_xt.cc +++ b/gpsbabel/garmin_xt.cc @@ -355,7 +355,7 @@ format_garmin_xt_proc_atrk(void) track = route_head_alloc(); // header option was not set to ignore if (method !=1) { - track->rte_name = xstrdup("ATRK XT"); + track->rte_name = "ATRK XT"; } track_add_head(track); } diff --git a/gpsbabel/gbfile.cc b/gpsbabel/gbfile.cc index 7244e7390..af06e9761 100644 --- a/gpsbabel/gbfile.cc +++ b/gpsbabel/gbfile.cc @@ -1013,7 +1013,7 @@ gbfgetcstr(gbfile* file) * The result is a temporary allocated entity: use it or free it! */ -char* +QString gbfgetpstr(gbfile* file) { int len; @@ -1026,7 +1026,9 @@ gbfgetpstr(gbfile* file) } result[len] = '\0'; - return result; + QString r(result); + xfree(result); + return r; } static char* diff --git a/gpsbabel/gbfile.h b/gpsbabel/gbfile.h index 217de1ef0..b23f1e923 100644 --- a/gpsbabel/gbfile.h +++ b/gpsbabel/gbfile.h @@ -123,7 +123,7 @@ int16_t gbfgetint16(gbfile* file); double gbfgetdbl(gbfile* file); // read a double value float gbfgetflt(gbfile* file); // read a float value char* gbfgetstr(gbfile* file); // read until any type of line-breaks or EOF -char* gbfgetpstr(gbfile* file); // read a pascal string +QString gbfgetpstr(gbfile* file); // read a pascal string char* gbfgetcstr(gbfile* file); // read a null terminated string int gbfputint16(const int16_t i, gbfile* file); diff --git a/gpsbabel/googledir.cc b/gpsbabel/googledir.cc index 8f10e2e2a..f9dc44c32 100644 --- a/gpsbabel/googledir.cc +++ b/gpsbabel/googledir.cc @@ -102,8 +102,8 @@ goog_poly_e(xg_string args, const QXmlStreamAttributes* unused) #else if (strcmp(args, "overview_polyline") == 0) { #endif - routehead->rte_name = (char*) xstrdup("overview"); - routehead->rte_desc = (char*) xstrdup("Overview"); + routehead->rte_name = "overview"; + routehead->rte_desc = "Overview"; } else { goog_step++; xasprintf(&routehead->rte_name, "step%03d", goog_step); @@ -113,7 +113,9 @@ goog_poly_e(xg_string args, const QXmlStreamAttributes* unused) utf_string utf; utf.is_html = 1; utf.utfstring = /*QString::fromUtf8*/(instructions); - routehead->rte_desc = strip_html(&utf); + char *s = strip_html(&utf); + routehead->rte_desc = s; + xfree(s); instructions = QString(); } } diff --git a/gpsbabel/gpsutil.cc b/gpsbabel/gpsutil.cc index 9deedfde7..ea60883b0 100644 --- a/gpsbabel/gpsutil.cc +++ b/gpsbabel/gpsutil.cc @@ -113,7 +113,7 @@ data_read(void) wpt_tmp = waypt_new(); wpt_tmp->altitude = alt; wpt_tmp->shortname = sn; - wpt_tmp->description = xstrdup(desc); + wpt_tmp->description = desc; wpt_tmp->SetCreationTime(now); if (latdir == 'S') { -- 2.30.2